package com.smartstate.admin.biz.util;

import com.smartstate.admin.biz.model.LoginUser;
import org.springframework.security.core.context.SecurityContextHolder;


public class UserUtils {

    public static LoginUser getLoginUser() {
        //判断是否可以转换
        Object principal = SecurityContextHolder.getContext().getAuthentication().getPrincipal();
        if (principal instanceof LoginUser) {
            return (LoginUser) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
        }
        return null;
    }
}
